/**
 * Created by Intellij IDEA
 *
 * @author 王俊凯
 * @Date: 2023/2/27 19:52
 * @Version 1.0
 */
package com.eight.controller;

import com.eight.pojo.TbCarType;
import com.eight.service.CarTypeService;
import com.eight.vo.CarVo;
import com.eight.vo.ComResult;
import com.eight.vo.MyObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rent/cartype")
public class CarTypeController {

    @Autowired
    private CarTypeService carTypeService;

    @RequestMapping("/list")
    public ComResult list(@RequestBody CarVo carVo){
        if (MyObjectUtils.objectCheckIsNull(carVo)){
            ComResult selectAllType = carTypeService.selectAllType();
            System.out.println(selectAllType);
            return selectAllType;
        }
        ComResult selectAllType = carTypeService.selectAllType(carVo);
        System.out.println(selectAllType);
        return selectAllType;
    }

    @RequestMapping("/insert")
    public ComResult insert(@RequestBody TbCarType type){
        return carTypeService.insert(type);
    }

    @RequestMapping("/update")
    public ComResult update(@RequestBody TbCarType type){
        return carTypeService.update(type);
    }

    @RequestMapping("/delete")
    public ComResult delete(Integer id){
        return carTypeService.delete(id);
    }

    /**
     * 查询移动端的所有车辆
     * @return
     */
    @GetMapping("/getCarType")
    public ComResult getCarType(){
        return carTypeService.getCarType();
    }

}

